package com.then.recruitment.request;

import android.content.Context;

import com.android.volley.AuthFailureError;
import com.android.volley.Response;
import com.android.volley.toolbox.StringRequest;
import com.then.recruitment.R;
import com.then.recruitment.utils.VersionManager;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by wk on 15/3/10.
 */
public class R_StringRequest extends StringRequest {
    public String paramsEncoding="utf-8";
    public Map<String,String> params = new HashMap<String,String>();
    public R_StringRequest(int method, String url, Response.Listener<String> listener, Response.ErrorListener errorListener) {
        super(method, url, listener, errorListener);
        initNetworkParam();
    }

    public R_StringRequest(String url, Response.Listener<String> listener, Response.ErrorListener errorListener) {
        super(url, listener, errorListener);
        initNetworkParam();
    }
    private void initNetworkParam()
    {

        String versionName = VersionManager.getVersionName(requestContext);
        int versionCode = VersionManager.getVersionCode(requestContext);
        params.put("versionName",versionName);
        params.put("versionCode",versionCode+"");
        params.put("appName",requestContext.getResources().getString(R.string.app_name_en));
        params.put("token",token);
        params.put("os","android");
    }



    @Override
    protected Map<String, String> getParams() throws AuthFailureError {
        return this.params;
    }
    public void addParams(String key,String value)
    {
        params.put(key, value);
    }
    @Override
    protected String getParamsEncoding() {
       return this.paramsEncoding;
    }

}
